package com.hzw.saas.common.open.service;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzw.saas.common.open.mapper.SaasClientMapper;
import com.hzw.saas.common.open.pojo.model.SaasClient;
import com.hzw.saas.common.util.SnowFlakeUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author sonam
 * @since 2021/3/1 9:44
 */
@RequiredArgsConstructor
@Service("saasClientServiceImpl")
public class SaasClientServiceImpl extends ServiceImpl<SaasClientMapper, SaasClient> implements ISaasClientService {

    @Override
    public void registerSaasClient(SaasClient saasClient) {
        saasClient.setId(SnowFlakeUtil.nextIdStr());
        saasClient.setCreateDate(new Date());
        saasClient.setAutoApprove(true);
        saasClient.setClientSecret(IdUtil.simpleUUID());
        this.save(saasClient);
    }

}
